<?php

namespace backend\controllers;

use common\models\SysUser;

class  PublicController extends \yii\web\Controller
{
    /**
     * 登陆方法()
     */
    public function actionLogin()
    {
        /*$post = [
            'SysUser' => [
                'login_name' => '654321',
                'password' => '123456'
            ]
        ];*/
        $model = new SysUser();
        $model->setScenario('login');
        \Yii::$app->session->destroy();
        if ($model->load(\Yii::$app->request->post()) && $model->login()) {
            //return $this->redirect(['system/site/index']);
            return $this->redirect(['system/site/animation']);
        } else {
            return $this->renderPartial('login', ['model' => $model]);
        }
    }

    /**
     * 修改密码发法
     */
    public function actionEditpass()
    {
        $post = [
            'SysUser' => [
                'password' => '1234567',
                'newPassword' => '123456'
            ]
        ];
        $model = new SysUser();
        $model->setScenario('editPass');
        if ($model->load($post) && $model->editPassword() !== false) {
            echo '修改成功';
        } else {
            var_dump($model->getErrors());
        }
    }
}